package cn.fl.risk.controller;

import cmm.comm.facade.framework.api.ISysDictionaryApiService;
import cmm.comm.facade.framework.dto.SysDictionaryDTO;
import cmm.mid.core.framework.page.DataResultVO;
import cmm.mid.core.framework.page.KeyValueVO;
import cmm.mid.core.framework.page.ListPageVO;
import cmm.mid.core.framework.page.Pager;
import cmm.user.facade.system.api.ISysUsrQueryApiService;
import cmm.user.facade.system.condition.SysUsrQueryCondition;
import cmm.user.facade.system.dto.SysUsrDTO;
import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.constant.BaseConstant;
import cn.cmm.base.framework.exception.BaseException;
import cn.cmm.base.framework.utils.*;
import cn.fl.audit.constant.AudStandingBookConstant;
import cn.fl.audit.service.IAudCreditInfoService;
import cn.fl.audit.service.IAudReturnVisitService;
import cn.fl.audit.service.IAudVisitRecordService;
import cn.fl.audit.vo.AudOpeLineVO;
import cn.fl.audit.vo.AudReturnVisitVO;
import cn.fl.capital.condition.CapFundSummaryQueryCondition;
import cn.fl.capital.condition.CapOverdueInfoQueryCondition;
import cn.fl.capital.condition.CapPayInfoQueryCondition;
import cn.fl.capital.constant.CapitalConstant;
import cn.fl.capital.service.ICapFundSummaryService;
import cn.fl.capital.service.ICapOverdueInfoService;
import cn.fl.capital.service.ICapPayInfoService;
import cn.fl.capital.vo.CapFundSummaryVO;
import cn.fl.capital.vo.CapOverdueInfoVO;
import cn.fl.capital.vo.CapPayInfoVO;
import cn.fl.customer.service.ICstBscInfoService;
import cn.fl.customer.service.ICstNpBscInfoService;
import cn.fl.customer.vo.CstBscInfoVO;
import cn.fl.customer.vo.CstNpBscInfoVO;
import cn.fl.export.condition.CapFundSummaryExportCondition;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.framework.constant.DictionaryConstant;
import cn.fl.preloan.IAuditOpeLineService;
import cn.fl.preloan.dto.audit.AuditOpeLineDTO;
import cn.fl.preloan.dto.audit.GetAudOpeLineByVisitIdRequest;
import cn.fl.project.condition.PrjBscInfoQueryCondition;
import cn.fl.project.condition.PrjPrdBscInfoQueryCondition;
import cn.fl.project.service.IPrjBscInfoService;
import cn.fl.project.service.IPrjPrdBscInfoService;
import cn.fl.project.service.IPrjPrdPaySchMService;
import cn.fl.project.vo.PrjBscInfoVO;
import cn.fl.project.vo.PrjPrdBscInfoVO;
import cn.fl.ref.fribaseinfo.service.IFriBaseInfoService;
import cn.fl.ref.fribaseinfo.vo.FriBaseInfoVO;
import cn.fl.risk.constant.RiskConstant;
import cn.fl.risk.service.IRskRentRemindService;
import cn.fl.risk.util.ExportRiskUtil;
import cn.fl.risk.vo.RskPayPrdTypRVO;
import cn.fl.system.constant.SysLogConstant;
import cn.fl.system.service.ISysRegionService;
import cn.fl.warrant.service.IArcMgrMainService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import cn.fl.commons.result.ResponseData;
import fl.ref.fribaseinfo.condition.FriBaseInfoQueryCondition;
import fl.ref.fribaseinfo.constant.FriBaseInfoConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.*;

/**
 * @Description: 催收催收 控制层
 */
@Controller
@RequestMapping("/risk/ovdCollect")
public class RskOvdCollectController extends BaseController {
	private static final Logger logger = LoggerFactory.getLogger(RskOvdCollectController.class);
	@Autowired
	private IPrjPrdPaySchMService prjPrdPaySchMService;
	@Autowired
	private IArcMgrMainService arcMgrMainService;
    @Autowired
    private ICapFundSummaryService capFundSummaryService;
    @Autowired
    private ICapOverdueInfoService capOverdueInfoService;
    @Autowired
    private ICapPayInfoService capPayInfoService;
    @Autowired
    private IRskRentRemindService rskRentRemindService;
    @Autowired
    private ISysDictionaryApiService sysDictionaryApiService ;
    
	@Autowired
	private IAudCreditInfoService audCreditInfoService;
    /**
     * 客户 服务层BEAN
     */
    @Autowired
    private ICstBscInfoService cstBscInfoService;
	@Autowired
	private IFriBaseInfoService friBaseInfoService;//融资机构基础信息表
	@Autowired
	private IPrjBscInfoService prjBscInfoService;//项目基础信息表
	@Autowired
	private IAudReturnVisitService audReturnVisitService;
	@Autowired
	private IAudVisitRecordService audVisitRecordService;
	
	
	/**
	 * 项目产品信息服务
	 */
	@Autowired
	private IPrjPrdBscInfoService prjPrdBscInfoService;
	
	@Autowired
	private ISysUsrQueryApiService sysUsrQueryApiService;
	@Autowired
	private ISysRegionService sysRegionService;

    @Autowired
    private IAuditOpeLineService auditOpeLineService;
    
    @Autowired
    private ICstNpBscInfoService cstNpBscInfoService;

    /*******************************
     * 到逾期催收管理页面
     *******************************/
    @RequestMapping(value = "/toMgrPage.do", method = {RequestMethod.GET})
    public ModelAndView toListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "加载到逾期催收管理页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("risk/ovdCollect/overdueCollect");
        return mav;
    }

    /*******************************
     * 到逾期任务列表页面
     *******************************/
    @RequestMapping(value = "/toOvdListPage.do", method = {RequestMethod.GET})
    public ModelAndView toOvdListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toOvdListPage", "加载到逾期任务列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView();
        String queryType = request.getParameter("queryType");
        mav.addObject("queryType", queryType);
        if ("1".equals(queryType)) {//逾期任务列表
            mav.setViewName("capital/capOverdueInfo/capOverdueInfoList");
        } else if ("2".equals(queryType)) {//组任务列表
            mav.setViewName("risk/ovdCollect/groupTaskList");
        } else if ("3".equals(queryType)) {//我的任务列表
        	HttpSession session = request.getSession(false);
            String userid = ""+CurrentThreadContext.getCurrentUserId();
            session.setAttribute("SESSION_USERNAME", userid);
            mav.setViewName("risk/ovdCollect/myTaskList");
            mav.addObject("wsUri", JSON.toJSONString(PropertiesUtils.getProperty("risk.risk.properties.fl.web.risk.wsuri")));
        } else if ("4".equals(queryType)) {//逾期任务分配
            mav.setViewName("risk/rskUsrOrgR/ovdCollectTaskConfig");
        }
        //TODO 2017-12-12 ZT 加入货物种类
        List<KeyValueVO> searchPrdTypCdList = this.rskRentRemindService.searchPrdTypCdList();
        mav.addObject("prdTypCdList", JSON.toJSONString(searchPrdTypCdList));
        
       	//主货物大类
    	List<KeyValueVO> mainGdsTypCdList = this.audCreditInfoService.searchGoodsTypListByLvl("1");
    	mav.addObject("mainGdsTypCdList", mainGdsTypCdList);
        
        // 事业部
        List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
        mav.addObject("buOrgCdList", JSON.toJSONString(orgList));
        //查询项目类型
        List<KeyValueVO> projectTypeList = this.prjBscInfoService.getPrjTypCdALLKV();
    	mav.addObject("projectTypeList", projectTypeList);
        //查询第三方机构
		Pager page = new Pager();
		page.setCurrentPage(1);
		page.setEveryPage(Integer.MAX_VALUE);
		FriBaseInfoQueryCondition qc = new FriBaseInfoQueryCondition();
		qc.setInsSts(FriBaseInfoConstant.FRI_BASE_INFO_INS_STS_PASS);
		qc.setInsUseCd("2");
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		qc.setOrgCd(CurrentThreadContext.getCurrentOrgCd());
		page.setCondition(qc);
		Pager pager = this.friBaseInfoService.searchListPage(page);
		List<FriBaseInfoVO> list = (List<FriBaseInfoVO>) pager.getResultList();
		mav.addObject("friBaseList", list);	
        return mav;
    }

    /*******************************
     * 逾期催收，逾期支付表明细
     ******************************/
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/searchOvdDtlList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object searchDtlList(HttpServletRequest request, HttpServletResponse response) {
        ListPageVO<CapOverdueInfoVO> listPage = null;
        try {
        CapOverdueInfoQueryCondition qc = new CapOverdueInfoQueryCondition();
        String cstId = request.getParameter("cstId");//客户ID
        String queryType = request.getParameter("queryType");
        String cstMgrNm = request.getParameter("cstMgrNm");
        String cstMgrId = request.getParameter("cstMgrId");
        String fundRasInsId = request.getParameter("fundRasInsId");
        String prjTypCd = request.getParameter("prjTypCd");
        String insCode = request.getParameter("insCode");
        
        if (StringUtils.isNotBlank(prjTypCd)) {
			qc.setPrjTypCd(prjTypCd);
		}
        if(StringUtils.isNotBlank(fundRasInsId)){
			qc.setFundRasInsId(Long.valueOf(fundRasInsId));
		}
        if (StringUtils.isNotEmpty(cstId)) {
            qc.setCstId(Long.valueOf(cstId));
        }
        String paySchId = request.getParameter("paySchId");//支付表ID
        if (StringUtils.isNotEmpty(paySchId)) {
            qc.setPaySchId(Long.parseLong(paySchId));
        }

        if(StringUtils.isNotBlank(insCode)){
			qc.setInsCode(insCode);
		}
        // what the fuck
        if (StringUtils.isNotEmpty(cstMgrId) && !cstMgrId.equals("null")) {
            qc.setAdditionalCondition(" AND CPI.CST_MGR_ID = '"+cstMgrId+"'");
        }else{
            if (StringUtils.isNotEmpty(cstMgrNm) && !cstMgrNm.equals("null")) {
                qc.setAdditionalCondition(" AND CPI.CST_MGR_NM = '" + cstMgrNm + "'");
            }
        }
        qc.setDataStatusCd(CapitalConstant.CODE_OVD_DATA_CD_0);
        /*List stsCdList = new ArrayList(2);
        stsCdList.add(CapitalConstant.CODE_OVD_STATUS_CD_0);
        stsCdList.add(CapitalConstant.CODE_OVD_STATUS_CD_1);
        qc.setOverdueStatusCdList(stsCdList);*/
        qc.setCreateDate(new Date());//罚息日期是当日
        BaseLogUtils.info(logger, "/risk/ovdCollect", "初始化逾期催收支付表明细列表数据.DATA:{cstId:" + cstId + "}", CurrentThreadContext.getCurrentUserName());
        List<CapOverdueInfoVO> list = null ;
        if(StringUtils.isNotBlank(queryType) && "3".equals(queryType)){
            list = this.capOverdueInfoService.searchMyOvdPayDtlList(qc);
        }else if(StringUtils.isNotBlank(queryType) && "1".equals(queryType)){
            qc.setAdditionalCondition(" AND (T.overdue_amount+T.penalty_amount-T.pay_amount-T.REDU_AMOUNT) >0");
            list = this.capOverdueInfoService.searchOvdPayDtlList(qc);
        }else{
            list = this.capOverdueInfoService.searchOvdPayDtlList(qc);
        }
        
      //TODO  2017-12-15  15:59:13 ZT查询 支付表与货物种类关联表
		List<Long> paySchIdList=new ArrayList<>(list.size());
		for(CapOverdueInfoVO vo:list){
			paySchIdList.add(vo.getPaySchId());
		}
		List<RskPayPrdTypRVO> searchTypeList =null;
		if(CollectionUtils.isNotEmpty(paySchIdList)){
		searchTypeList = this.rskRentRemindService.searchTypeList(paySchIdList);
		}
		if(CollectionUtils.isNotEmpty(searchTypeList)){
			for (int i = 0; i < list.size(); i++) {
				for (int j = 0; j < searchTypeList.size(); j++) {
					if(list.get(i).getPaySchId().equals(searchTypeList.get(j).getPaySchId())){
						list.get(i).setPrdTypCd(searchTypeList.get(j).getPrdTypCd());
					}
				}
			}
		}
		
		//TODO  2017 -12-15 16:18:23  ZT  
		Map<String, String> _CdMap = this.sysDictionaryApiService.searchGroupToMap(
		CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), RiskConstant.CODE_RSK_PAY_PRD_TYP_R_CD);
			/*  过滤后的字典表数据
			 * List<SysDictionaryDTO> searchGroupWithLevel =  this.sysDictionaryApiService.searchGroupWithLevel(
					CurrentThreadContext.getCurrentSysCd(),CurrentThreadContext.getCurrentOrgCd(),
					RiskConstant.CODE_RSK_PAY_PRD_TYP_R_CD, Integer.parseInt(RiskConstant.CODE_RSK_PAY_PRD_TYP_R_CODE_LVL));*/
			for(CapOverdueInfoVO vo:list){
				if (_CdMap != null && _CdMap.containsKey(vo.getPrdTypCd())) {
	            	vo.setPrdTypCdNm(_CdMap.get(vo.getPrdTypCd()));
	        	}
			}
            listPage = new ListPageVO<CapOverdueInfoVO>(list, list.size());
        }catch (Exception e){
            BaseLogUtils.error(logger,"searchDtlList",e.getMessage());
            throw e;
        }
        return listPage;
    }

    /*****************************
     * 到罚息管理列表页面
     *****************************/
    @RequestMapping(value = "/toFineListPage.do", method = {RequestMethod.GET})
    public ModelAndView toFineListPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toFineListPage", "加载到罚息管理列表页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("capital/capFundSummary/capCstFineList");
        return mav;
    }

    /*****************************
     * 到计算应收金额页面
     *****************************/
    @RequestMapping(value = "/toCalcAmtPage.do", method = {RequestMethod.GET})
    public ModelAndView toCalcAmtPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toCalcAmtPage", "加载到计算应收金额页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView mav = new ModelAndView("risk/ovdCollect/interestCalculation");
        String cstId = request.getParameter("cstId");//客户ID
        String ovdDays = request.getParameter("ovdDays");//逾期天数
        String recAmt = request.getParameter("recAmt");//应收金额
        String fineAmt = request.getParameter("fineAmt");//罚息金额

        mav.addObject("cstId", cstId);
        mav.addObject("ovdDays", ovdDays);
        mav.addObject("recAmt", recAmt);
        mav.addObject("fineAmt", fineAmt);
        mav.addObject("createDate", DateUtils.formatDateToString(new Date(), DateUtils.YYYY_MM_DD));//计算日期默认当天
        return mav;
    }

    /***********************
     * 初始化逾期催收列表
     ***********************/
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initOvdList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initOvdList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        CapFundSummaryQueryCondition qc = new CapFundSummaryQueryCondition();
        String queryType = request.getParameter("queryType");//类型：1.逾期任务 2.组任务 3.我的任务
        String cstNm = request.getParameter("cstNm");
        String lsCntNo = request.getParameter("lsCntNo");
        String buOrgCds = request.getParameter("buOrgCd");
        String ovdDtMin = request.getParameter("ovdDtMin");
        String ovdDtMax = request.getParameter("ovdDtMax");
        String ovdDaysMin = request.getParameter("ovdDaysMin");
        String ovdDaysMax = request.getParameter("ovdDaysMax");
        String ovdAmtMin = request.getParameter("ovdAmtMin");
        String ovdAmtMax = request.getParameter("ovdAmtMax");
        String allocationFlag=request.getParameter("allocationFlag");
        String usrNm = request.getParameter("usrNm");
        String cstMgrNm = request.getParameter("cstMgrNm");
        String prjTypCd = request.getParameter("prjTypCd");
        String insCode = request.getParameter("insCode");

        List<String> buOrgCdList = new ArrayList<>();
        if(StringUtils.isNotBlank(buOrgCds)){
            String[] buOrgCdStr = buOrgCds.split(";");
            if(buOrgCdStr.length>0){
                for (String str : buOrgCdStr) {
                    buOrgCdList.add(str);
                }
            }
        }

        if (StringUtils.isNotEmpty(queryType)) {
            qc.setQueryType(queryType);
        }
        if (StringUtils.isNotEmpty(cstNm)) {
            qc.setCstNm(cstNm);
        }
        if (StringUtils.isNotBlank(lsCntNo)) {
            qc.setLsCntNo(lsCntNo.trim());
        }
        if (CollectionUtils.isNotEmpty(buOrgCdList)) {
            qc.setBuOrgCdList(buOrgCdList);
        }
        if (StringUtils.isNotBlank(ovdDtMin)) {
            qc.setOvdDtMin(ovdDtMin);
        }
        if (StringUtils.isNotBlank(ovdDtMax)) {
            qc.setOvdDtMax(ovdDtMax);
        }
        if (StringUtils.isNotBlank(ovdDaysMin)) {
            qc.setOvdDaysMin(Integer.valueOf(ovdDaysMin));
        }
        if (StringUtils.isNotBlank(ovdDaysMax)) {
            qc.setOvdDaysMax(Integer.valueOf(ovdDaysMax));
        }
        if (StringUtils.isNotBlank(ovdAmtMax) && StringUtils.isUnsignedNumeric(ovdAmtMax)) {
            Double amtMax = 100 * Double.parseDouble(ovdAmtMax);
            qc.setOvdAmtMax(amtMax.longValue());
        }
        if (StringUtils.isNotBlank(ovdAmtMin) && StringUtils.isUnsignedNumeric(ovdAmtMin)) {
            Double amtMin = 100 * Double.parseDouble(ovdAmtMin);
            qc.setOvdAmtMin(amtMin.longValue());
        }
        if(StringUtils.isNotBlank(allocationFlag)){
            qc.setAllocationFlag(Integer.parseInt(allocationFlag));
        }
        if(StringUtils.isNotBlank(usrNm)){
            qc.setUsrNm(usrNm);
        }
        if(StringUtils.isNotBlank(cstMgrNm)){
            qc.setCstMgrNm(cstMgrNm);
        }
        if (StringUtils.isNotEmpty(prjTypCd)) {
        	qc.setPrjTypCd(prjTypCd);;
        }
        if(StringUtils.isNotBlank(insCode)){
			qc.setInsCode(insCode);
		}
        /*if (StringUtils.isNotEmpty(fundRasInsId)) {
        	qc.setFundRasInsId(Long.valueOf(fundRasInsId));
        }*/
        page.setCondition(qc);

        BaseLogUtils.info(logger, "initOvdList", "初始化逾期催收列表数据.DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
        Pager pager = this.capFundSummaryService.searchOvdListPage(page);
        List<CapFundSummaryVO> list = (List<CapFundSummaryVO>) pager.getResultList();
        ListPageVO<CapFundSummaryVO> listPage = new ListPageVO<CapFundSummaryVO>(list, pager.getTotalCount());
        return listPage;
    }

    /******************************
     * 查询逾期汇总金额
     * @param request
     * @param response
     * @return
     * @throws BaseException
     *********************************/
    @RequestMapping(value = "/ovdAmtSummary.do", method = {RequestMethod.GET})
    @ResponseBody
    public DataResultVO ovdAmtSummary(HttpServletRequest request, HttpServletResponse response) throws BaseException {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功");

        CapFundSummaryQueryCondition qc = new CapFundSummaryQueryCondition();
        String queryType = request.getParameter("queryType");//类型：1.逾期任务 2.组任务 3.我的任务
        String cstNm = request.getParameter("cstNm");
        String lsCntNo = request.getParameter("lsCntNo");
        String buOrgCds = request.getParameter("buOrgCd");
        String ovdDtMin = request.getParameter("ovdDtMin");
        String ovdDtMax = request.getParameter("ovdDtMax");
        String ovdDaysMin = request.getParameter("ovdDaysMin");
        String ovdDaysMax = request.getParameter("ovdDaysMax");
        String cstMgrNm = request.getParameter("cstMgrNm");
        String allocationFlag=request.getParameter("allocationFlag");


        List<String> buOrgCdList = new ArrayList<>();
        if(StringUtils.isNotBlank(buOrgCds)){
            String[] buOrgCdStr = buOrgCds.split(";");
            if(buOrgCdStr.length>0){
                for (String str : buOrgCdStr) {
                    buOrgCdList.add(str);
                }
            }
        }

        if (StringUtils.isNotEmpty(queryType)) {
            qc.setQueryType(queryType);
        }
        if (StringUtils.isNotEmpty(cstNm)) {
            qc.setCstNm(cstNm);
        }
        if (StringUtils.isNotBlank(lsCntNo)) {
            qc.setLsCntNo(lsCntNo.trim());
        }
        if (CollectionUtils.isNotEmpty(buOrgCdList)) {
            qc.setBuOrgCdList(buOrgCdList);
        }
        if (StringUtils.isNotBlank(ovdDtMin)) {
            qc.setOvdDtMin(ovdDtMin);
        }
        if (StringUtils.isNotBlank(ovdDtMax)) {
            qc.setOvdDtMax(ovdDtMax);
        }
        if (StringUtils.isNotBlank(ovdDaysMin)) {
            qc.setOvdDaysMin(Integer.valueOf(ovdDaysMin));
        }
        if (StringUtils.isNotBlank(ovdDaysMax)) {
            qc.setOvdDaysMax(Integer.valueOf(ovdDaysMax));
        }
        if(StringUtils.isNotBlank(cstMgrNm)){
            qc.setCstMgrNm(cstMgrNm);
        }
        if(StringUtils.isNotBlank(allocationFlag)){
            qc.setAllocationFlag(Integer.parseInt(allocationFlag));
        }
        try {
            CapFundSummaryVO vo = this.capFundSummaryService.selectOvdAmtSummary(qc);
            if (null == vo) {
                vo = new CapFundSummaryVO();
                vo.setFineAmt(0L);
                vo.setArAmt(0L);
                vo.setOvdAmt(0L);
            } else {
                vo.setArAmt(vo.getFineAmt() + vo.getOvdAmt());
            }
            result.setData(vo);
        } catch (BaseException ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.info(logger, "ovdAmtSummary", "查询逾期汇总金额失败,Condition:" + JSON.toJSONString(qc) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        } catch (Exception ex) {
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo(SysLogConstant.LOG_CMM_SYS_ERROR);
            BaseLogUtils.error(logger, "ovdAmtSummary", "查询逾期汇总金额失败,系统错误.Condition:" + JSON.toJSONString(qc) + ".ERROR:" + ex.getMessage(), CurrentThreadContext.getCurrentUserName());
        }
        return result;
    }

    /*******************************
     * 初始化罚息管理列表
     *******************************/
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/initFineList.do", method = {RequestMethod.GET})
    @ResponseBody
    public Object initFineList(HttpServletRequest request, HttpServletResponse response) {
        String currentPage = request.getParameter("page");
        String pageSize = request.getParameter("pagesize");
        Pager page = new Pager();
        if (StringUtils.isNotEmpty(currentPage)) {
            page.setCurrentPage(Integer.parseInt(currentPage));
        }

        if (StringUtils.isNotEmpty(pageSize)) {
            page.setEveryPage(Integer.parseInt(pageSize));
        }

        CapFundSummaryQueryCondition qc = new CapFundSummaryQueryCondition();
        String cstNm = request.getParameter("cstNm");
        String ovdAmtMin = request.getParameter("ovdAmtMin");
        String ovdAmtMax = request.getParameter("ovdAmtMax");
        String fineAmtMin = request.getParameter("fineAmtMin");
        String fineAmtMax = request.getParameter("fineAmtMax");
        if (StringUtils.isNotEmpty(cstNm)) {
            qc.setCstNm(cstNm);
        }
        if (StringUtils.isNotBlank(ovdAmtMin)) {
            qc.setOvdAmtMin(DecimalUtils.convertYuanToFen(Double.valueOf(ovdAmtMin)));
        }
        if (StringUtils.isNotBlank(ovdAmtMax)) {
            qc.setOvdAmtMax(DecimalUtils.convertYuanToFen(Double.valueOf(ovdAmtMax)));
        }
        if (StringUtils.isNotBlank(fineAmtMin)) {
            qc.setFineAmtMin(DecimalUtils.convertYuanToFen(Double.valueOf(fineAmtMin)));
        } else {
            qc.setFineAmtMin(0L);
        }
        if (StringUtils.isNotBlank(fineAmtMax)) {
            qc.setFineAmtMax(DecimalUtils.convertYuanToFen(Double.valueOf(fineAmtMax)));
        }
        qc.setCrtDt(Long.valueOf(DateUtils.formatDateToString(new Date(), DateUtils.YYYYMMDD)));
        page.setCondition(qc);

        BaseLogUtils.info(logger, "initFineList", "初始化罚息管理列表页面数据.DATA:" + JSONObject.toJSONString(page), CurrentThreadContext.getCurrentUserName());
        Pager pager = this.capFundSummaryService.searchFineListPage(page);
        List<CapFundSummaryVO> list = (List<CapFundSummaryVO>) pager.getResultList();
        ListPageVO<CapFundSummaryVO> listPage = new ListPageVO<CapFundSummaryVO>(list, pager.getTotalCount());
        return listPage;
    }

    /**
     * 导出沟通记录
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/exportFineList.do", method = {RequestMethod.GET, RequestMethod.POST})
    public void exportFineList(HttpServletRequest request, HttpServletResponse response) {
        CapOverdueInfoQueryCondition condition = new CapOverdueInfoQueryCondition();
        condition.setCreateDate(DateUtils.formatDate(new Date(), DateUtils.YYYY_MM_DD));
        String cstId = request.getParameter("cstId");//客户ID
        if (StringUtils.isNotEmpty(cstId)) {
            condition.setCstId(Long.valueOf(cstId));
        }
        BaseLogUtils.info(logger, "exportFineList", "导出罚息明细=" + JSON.toJSONString(condition));
        List<CapOverdueInfoVO> voList = this.capOverdueInfoService.searchOvdPayList(condition);
        Map<String, Object> map = new HashMap<>();
        map.put("fineList", voList);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        String now = DateUtils.formatDateToString(new Date(), DateUtils.YYYYMMDDHHMMSS);
        String filename = "罚息明细" + now;
        response.setCharacterEncoding("utf-8");
        OutputStream os = null;
        try {
            filename = new String(filename.getBytes("utf-8"), "ISO8859-1");
            response.setHeader("Content-disposition", "attachment; filename=" + filename + ".xls");// 设定输出文件头
            response.setContentType("application/x-msdownload");// 定义输出类型
            baos = new ExportRiskUtil().exportFineXls(map);
            if (baos == null) {
                BaseLogUtils.error(logger, "exportFineList", "导出罚息明细失败");
                return;
            }
            os = response.getOutputStream();
            baos.writeTo(os);
            baos.flush();
            os.flush();
        } catch (UnsupportedEncodingException e) {
			BaseLogUtils.error(logger, "-", "异常", e);
            BaseLogUtils.error(logger, "exportFineList", "导出罚息明细失败" + e.getMessage());
        } catch (IOException e) {
			BaseLogUtils.error(logger, "-", "异常", e);
            BaseLogUtils.error(logger, "exportFineList", "导出罚息明细失败" + e.getMessage());
        } finally {
            //关闭流
            if (os != null) {
                try {
                    os.close();
                } catch (IOException e) {
			BaseLogUtils.error(logger, "-", "异常", e);
                }
            }
            if (baos != null) {
                try {
                    baos.close();
                } catch (IOException e) {
			BaseLogUtils.error(logger, "-", "异常", e);
                }
            }

        }
    }
    /**
     * 批量导出逾期数据
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/exportOverdueInfoList.do", method = {RequestMethod.POST})
    @ResponseBody
    public DataResultVO exportOverdueInfoList(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger,"exportOverdueInfoList","批量导出逾期数据==操作人:"+CurrentThreadContext.getCurrentUserId());
        CapFundSummaryExportCondition qc = new CapFundSummaryExportCondition();
        String queryType = request.getParameter("queryType");//类型：1.逾期任务 2.组任务 3.我的任务
        String cstNm=request.getParameter("cstNm");//客户名称
        String lsCntNo=request.getParameter("lsCntNo");//合同编号
		String buOrgCd=request.getParameter("buOrgCd");//事业部
		String insCode=request.getParameter("insCode");//资管机构
		String ovdDaysMin=request.getParameter("ovdDaysMin");//逾期最小天数
		String ovdDaysMax=request.getParameter("ovdDaysMax");//逾期最大天数
		String ovdDtMin=request.getParameter("ovdDtMin");//应收最小日期
		String ovdDtMax=request.getParameter("ovdDtMax");//应收最大日期
        String cstMgrNm=request.getParameter("cstMgrNm");
        String allocationFlag=request.getParameter("allocationFlag");
        String bizFlag=request.getParameter("bizFlag");
        String mcrCd=request.getParameter("mcrCd");
        if(StringUtils.isNotBlank(bizFlag)){
            qc.setBizFlag(bizFlag);
        }
        if(StringUtils.isNotBlank(mcrCd)){
            qc.setMcrCd(mcrCd);
        }
        if(StringUtils.isNotBlank(allocationFlag)){
            qc.setAllocationFlag(Integer.parseInt(allocationFlag));
        }
		if(StringUtils.isNotBlank(queryType)){
			qc.setQueryType(queryType);
		}
		if(StringUtils.isNotBlank(cstNm)){
			qc.setCstNm(cstNm.trim());
		}
		if(StringUtils.isNotBlank(lsCntNo)){
			qc.setLsCntNo(lsCntNo.trim());
		}
		if(StringUtils.isNotBlank(buOrgCd)){
            List<String> buOrgCdList = Arrays.asList(buOrgCd.split(";"));
            if(CollectionUtils.isNotEmpty(buOrgCdList)){
                qc.setBuOrgCdList(buOrgCdList);
            }
		}
		if(StringUtils.isNotBlank(insCode)){
            List<String> insCodeList = Arrays.asList(insCode.split(";"));
            if(CollectionUtils.isNotEmpty(insCodeList)){
                qc.setInsCodeList(insCodeList);
            }
        }
		if(StringUtils.isNotBlank(ovdDaysMin)){
			qc.setOvdDaysMin(Integer.valueOf(ovdDaysMin));
		}
		if(StringUtils.isNotBlank(ovdDaysMax)){
			qc.setOvdDaysMax(Integer.valueOf(ovdDaysMax));
		}
		if(StringUtils.isNotBlank(ovdDtMin)){
			qc.setOvdDtMin(ovdDtMin);
		}
		if(StringUtils.isNotBlank(ovdDtMax)){
			qc.setOvdDtMax(ovdDtMax);
		}
		if(StringUtils.isNotBlank(cstMgrNm)){
		    qc.setCstMgrNm(cstMgrNm);
        }
        return this.capFundSummaryService.exportOverdueList(qc);
    }


    /**
     * 查询放款数据
     */
    @SuppressWarnings("unchecked")
    @RequestMapping(value = "/getPayInfo.do", method = {RequestMethod.GET})
    @ResponseBody
    public DataResultVO getPayInfo(HttpServletRequest request, HttpServletResponse response) {
        DataResultVO result = new DataResultVO(BaseConstant.IS_YESNO_YES, "查询成功");
        String paySchId = request.getParameter("paySchId");
        if(StringUtils.isEmpty(paySchId)){
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("支付表ID不能为空");
            return result;
        }

        CapPayInfoQueryCondition condition = new CapPayInfoQueryCondition();
        condition.setPaySchId(Long.valueOf(paySchId));
        List<CapPayInfoVO> payInfoVOList = this.capPayInfoService.searchList(condition);
        if(CollectionUtils.isNotEmpty(payInfoVOList)){
            result.setData(payInfoVOList.get(0));
        }else{
            result.setSuccess(BaseConstant.IS_YESNO_NO);
            result.setInfo("未查到放款信息");
        }
        return result;
    }
    /*******************************
     * 到贷后回访管理页面
     *******************************/
    @RequestMapping(value = "/toLoanLaterPage.do", method = {RequestMethod.GET})
    public ModelAndView toLoanLaterPage(HttpServletRequest request, HttpServletResponse response) {
        BaseLogUtils.info(logger, "toListPage", "加载到贷后回访管理页面.", CurrentThreadContext.getCurrentUserName());
        ModelAndView view = new ModelAndView("risk/ovdCollect/LoanLaterReturnVisit");
        //项目类型
        List<KeyValueVO> projectTypeList = this.prjBscInfoService.getPrjTypCdALLKV();
        // 事业部
        List<KeyValueVO> orgList = this.cstBscInfoService.searchBusinessOrgList();
        //合同签署方式
        List<KeyValueVO> cntTypCdList = this.prjBscInfoService.getCntTypCdList();
        // 所属区域
        List<KeyValueVO> regionList = this.prjBscInfoService.getRegionList();

        view.addObject("projectTypeList", projectTypeList);
        view.addObject("orgList", orgList);
        view.addObject("cntTypCdList", cntTypCdList);
        view.addObject("regionList", regionList);
        //view.addObject("DHHF", DHHF);//标识
        //审批类型
        List<SysDictionaryDTO> SCHR6List = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(),DictionaryConstant.RC_CP_MOD_EXT_INFO_SCHR6);
        view.addObject("SCHR6List", SCHR6List);
        //省公司
        request.setAttribute("prList", arcMgrMainService.getPrList());

        return view;
    }
    /**
	 * 贷后回访初始化列表
	 */
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/LoanLaterinitList.do", method = { RequestMethod.GET })
	@ResponseBody
	public Object initList(HttpServletRequest request,HttpServletResponse response) {
		String currentPage = request.getParameter("page");
		String pageSize = request.getParameter("pagesize");
		String cstNm = request.getParameter("cstNm");//承租人
		String lsCntNo = request.getParameter("lsCntNo");//合同号
		String prjTyCd = request.getParameter("prjTypCd");//项目类型
		String prdQty = request.getParameter("prdQty");//资产数量
		String buOrgCd = request.getParameter("buOrgCd");// 事业部
		String cstMgrNm = request.getParameter("cstMgrNm");// 客户经理
		String cntTypCd = request.getParameter("cntTypCd");//合同签署方式
		String schr6= request.getParameter("schr6");//审批类型
		String auditorName = request.getParameter("auditorName");//信审员
		String returnVisitNm = request.getParameter("returnVisitNm");//信审员
		String cstMgrOrgCd = request.getParameter("cstMgrOrgCd");//所属公司
		String visitStatus = request.getParameter("visitStatus");//回访状态
        String cstMgrRgnCd = request.getParameter("cstMgrRgnCd");
		Pager page = new Pager();
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setCurrentPage(Integer.parseInt(currentPage));
		}
		if (StringUtils.isNotEmpty(currentPage)) {
			page.setEveryPage(Integer.parseInt(pageSize));
		}

		PrjBscInfoQueryCondition qc = new PrjBscInfoQueryCondition();
        if (StringUtils.isNotEmpty(cstMgrRgnCd)) {
            qc.setCstMgrRgnCd(cstMgrRgnCd);
        }
		if (StringUtils.isNotBlank(lsCntNo)) {
			qc.setLsCntNo(lsCntNo);
		}
		if (StringUtils.isNotBlank(cntTypCd)) {
			qc.setCntTypCd(cntTypCd);
		}
		if (StringUtils.isNotBlank(schr6)) {
			qc.setSchr_6(schr6);
		}
		if (StringUtils.isNotBlank(cstMgrNm)) {
			qc.setCstMgrNm(cstMgrNm);
		}
		if (StringUtils.isNotBlank(cstNm)) {
			qc.setCstNm(cstNm);
		}
		if (StringUtils.isNotBlank(prjTyCd)) {
			qc.setPrjTypCd(prjTyCd);
		}
		if (StringUtils.isNotEmpty(auditorName)) {
			qc.setAuditorName(auditorName);
		}
		if (StringUtils.isNotEmpty(cstMgrOrgCd)) {
			qc.setCstMgrOrgCd(cstMgrOrgCd);
		}
		if (StringUtils.isNotEmpty(buOrgCd)) {
			qc.setBuOrgCd(buOrgCd);
		}
		if (StringUtils.isNotEmpty(returnVisitNm)) {
			qc.setReturnVisitNm(returnVisitNm);
		}
		qc.setUsrId(CurrentThreadContext.getCurrentUserId());
		qc.setSysCd(CurrentThreadContext.getCurrentSysCd());
		page.setCondition(qc);
		Pager pager = this.prjBscInfoService.LoansearchListPage(page);
		List<PrjBscInfoVO> list = (List<PrjBscInfoVO>) pager.getResultList();
	ListPageVO<PrjBscInfoVO> listPage = new ListPageVO<PrjBscInfoVO>(list,pager.getTotalCount());
		
		return listPage;
	}
	/**
	 * 到新增/修改页面-回访信息 
	 */
	@RequestMapping(value = "/LoanLatertoAddPage.do", method = { RequestMethod.GET, RequestMethod.POST })
	public ModelAndView toAddPage(HttpServletRequest request, HttpServletResponse response) {
		String projectId = request.getParameter("projectId");//项目ID
		//String proIntId = request.getParameter("proIntId");//流程实例ID
		String prdTypCd = request.getParameter("prdTypCd");//项目产品类型
		//String isDetail = request.getParameter("isDetail");//是否详情标识(1:详情页面不可编辑,操作按钮隐藏)
		String buOrgCd = request.getParameter("buOrgCd");//项目所属事业部
		String DaiHou = request.getParameter("DaiHou");//判断是否是初审标识
		String taskDefKey = request.getParameter("taskDefKey");//项目所属事业部
		ModelAndView view = new ModelAndView("risk/ovdCollect/audReturnVisitAdd");
		view.addObject("projectId", projectId);
		view.addObject("DaiHou", DaiHou);
		view.addObject("taskDefKey", taskDefKey);
		
		AudReturnVisitVO vo = this.audReturnVisitService.selectByProjectIdAndProIntId(Long.valueOf(projectId));
		view.addObject("audReturnVisitvo", vo);
		//是否本人接听
		if(vo.getTenantVisitRecordVO() != null){
		view.addObject("isSelfAnswer", vo.getTenantVisitRecordVO().getIsSelfAnswer());
		//身份信息
		view.addObject("IdentityCd", vo.getTenantVisitRecordVO().getIdentityCd());
		view.addObject("AddressCd", vo.getTenantVisitRecordVO().getAddressCd());
		}
		if(vo !=null){
		//是否含挂车
		view.addObject("IsExistTrunc", vo.getIsExistTrunc());
		//提车情况
		view.addObject("PickCardCd", vo.getPickCardCd());
		//上牌情况
		view.addObject("StatusCd", vo.getStatusCd());
		//代扣卡
		view.addObject("AgentCardStateCd", vo.getAgentCardStateCd());
		//位置
		view.addObject("EqmtAddressCd", vo.getEqmtAddressCd());
		view.addObject("AffiliatedCompany", vo.getAffiliatedCompany());
		//担保人关系
		view.addObject("GuraRl", vo.getGuraRl());
		//担保人备注
		view.addObject("GuraRem", vo.getGuraRem());
		}
		if(vo.getAudVisitTkVO() != null){
		//收入方式
		view.addObject("ProfitCd", vo.getAudVisitTkVO().getProfitCd());
		//主货物大类
		view.addObject("MainGdsTypCd", vo.getAudVisitTkVO().getMainGdsTypCd());
		//主运输货物
		view.addObject("Goods", vo.getAudVisitTkVO().getGoods());
		//货物来源
		view.addObject("GoodsRes", vo.getAudVisitTkVO().getGoodsRes());
		//主货物结算方式
		view.addObject("GdsStlWayCd", vo.getAudVisitTkVO().getGdsStlWayCd());
		//司机情况
		view.addObject("Driver", vo.getAudVisitTkVO().getDriver());
		//第二还款来源
		view.addObject("SecondPayResCd", vo.getAudVisitTkVO().getSecondPayResCd());
		//挂靠公司
		
		//紧急联系人关系
		//view.addObject("GuraRl", vo.getg);
		//紧急联系人备注
		//view.addObject("AffiliatedCompany", vo.getg);
		//其他信息
		view.addObject("OtherInfo", vo.getAudVisitTkVO().getOtherInfo());
		}
		if(vo != null &&StringUtils.isNotBlank(vo.getCircuitType())){
			view.addObject("circuitType", vo.getCircuitType());
		}
		if(vo != null &&StringUtils.isNotBlank(vo.getCargoWeigth())){
			view.addObject("cargoWeigth", vo.getCargoWeigth());
		}
		if(vo != null &&StringUtils.isNotBlank(vo.getCargoVomule())){
			view.addObject("cargoVomule", vo.getCargoVomule());
		}
		if(vo != null &&StringUtils.isNotBlank(vo.getHandingMode())){
			view.addObject("handingMode", vo.getHandingMode());
		}
		if(vo != null &&StringUtils.isNotBlank(vo.getCircuitEfficiency())){
			view.addObject("circuitEfficiency", vo.getCircuitEfficiency());
		}
		if(vo != null &&StringUtils.isNotBlank( vo.getFare())){
			view.addObject("Fare", vo.getFare());
		}
		if(null != vo.getId()){
            GetAudOpeLineByVisitIdRequest getRequest = new GetAudOpeLineByVisitIdRequest();
            getRequest.setVisitId(vo.getId());
            getRequest.setSysCd(CurrentThreadContext.getCurrentSysCd());
            ResponseData<List<AuditOpeLineDTO>> responseData = auditOpeLineService.getAudvisitOperateLineByVisitId(getRequest);
            List<AudOpeLineVO> audOpeLineList = new ArrayList<>();
            if (responseData != null && ResponseData.SUCCESS_CODE.equals(responseData.getCode()) && responseData.getData() != null) {
                List<AuditOpeLineDTO> auditOpeLineDTOS = responseData.getData();
                for (AuditOpeLineDTO auditOpeLineDTO : auditOpeLineDTOS) {
                    AudOpeLineVO audOpeLineVO = new AudOpeLineVO();
                    BeanUtils.copyProperties(auditOpeLineDTO, audOpeLineVO);
                    audOpeLineList.add(audOpeLineVO);
                }
            }
	         if(null != audOpeLineList && audOpeLineList.size() !=0 ){
				view.addObject("audOpeLineList",audOpeLineList);
				view.addObject("size",audOpeLineList.size());
			}else{
				view.addObject("size",null);
			}
		}else{
			view.addObject("size",null);
		}
		
   

		
		if(StringUtils.isEmpty(prdTypCd)){
			PrjPrdBscInfoQueryCondition prjPrdQc = new PrjPrdBscInfoQueryCondition();
			if(StringUtils.isNotEmpty(projectId)){
				prjPrdQc.setPrjId(Long.valueOf(projectId));
			}
			List<PrjPrdBscInfoVO> prjPrdBscInfoVOList = this.prjPrdBscInfoService.searchList(prjPrdQc);
			if(CollectionUtils.isNotEmpty(prjPrdBscInfoVOList)){
				prdTypCd = prjPrdBscInfoVOList.get(0).getPrdTypCd();
			}
		}
		view.addObject("prdTypCd", prdTypCd);
	//	view.addObject("isDetail", isDetail);
		//查询承租人姓名 客户经理 
		try {
			if(StringUtils.isNotEmpty(projectId)){
				PrjBscInfoVO prjBscInfoVO = this.prjBscInfoService.selectById(Long.valueOf(projectId));
				if(null!=prjBscInfoVO){
					view.addObject("cstNm", prjBscInfoVO.getCstNm());//客户名称
					view.addObject("cstMgrId", prjBscInfoVO.getCstMgrId());//客户经理ID
					view.addObject("cstMgrNm", prjBscInfoVO.getCstMgrNm());//客户经理名称
					view.addObject("buOrgCd", prjBscInfoVO.getBuOrgCd());//项目所属事业部代码
					CstBscInfoVO cstBscInfoVO = cstBscInfoService.selectById(prjBscInfoVO.getCstId());
					CstNpBscInfoVO cstNpBscInfoVO = cstNpBscInfoService.selectById(prjBscInfoVO.getCstId());
					if(null != cstBscInfoVO){
						view.addObject("certNo",cstBscInfoVO.getCertNo());//身份证
					}else{
						view.addObject("certNo","");
					}
					if(null != cstNpBscInfoVO){
						view.addObject("postAddr",cstNpBscInfoVO.getPostAddr());//通信地址
					}else{
						view.addObject("postAddr","");
					}
				}
			}
		} catch (BaseException e) {
			BaseLogUtils.info(logger, "", "跳转回访信息页面查询项目信息发生异常.Detail:"+e.getMessage());
		} catch (Exception e) {
			BaseLogUtils.info(logger, "", "跳转回访信息页面查询项目信息发生异常.Detail:"+e.getMessage());
		}
		//查询当前登录人
		view.addObject("userId", CurrentThreadContext.getCurrentUserId());
		view.addObject("userNm", CurrentThreadContext.getCurrentUserName());
		/**
		 * 信审员 支持选择 而不是取当前登录人
		 */
		//查数据字典-->评审人员角色ID
		List<SysUsrDTO> auditUsrList = new ArrayList<SysUsrDTO>();
		List<SysDictionaryDTO> dicList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), RiskConstant.CODE_COLLECTOR_ROLE_CD);
		if(CollectionUtils.isNotEmpty(dicList)){
			SysDictionaryDTO sysDictionaryDTO = dicList.get(0);
			if(null!=sysDictionaryDTO){
				String roleIdString = sysDictionaryDTO.getCode();
				if(StringUtils.isNotEmpty(roleIdString)){
					auditUsrList = this.sysUsrQueryApiService.searchAuthSysUsrListByRoleId(Long.valueOf(roleIdString), CurrentThreadContext.getCurrentSysCd());//信审员集合
				}
			}
		}
		/**
		 * 预览担保人备注
		 */
		/*String previewGuarantorRem = "";
		if(StringUtils.isNotEmpty(projectId)){
			previewGuarantorRem = this.audReturnVisitService.previewGuarantorRem(Long.valueOf(projectId));
		}
		view.addObject("previewGuarantorRem", previewGuarantorRem);*/
		
		List<KeyValueVO> auditUsrKVList = new ArrayList<KeyValueVO>();
		if(CollectionUtils.isNotEmpty(auditUsrList)){
			for (SysUsrDTO sysUsrDTO : auditUsrList) {
				KeyValueVO kv = new KeyValueVO();
				kv.setKey(sysUsrDTO.getId().toString());
				kv.setValue(sysUsrDTO.getRefRlNm());
				auditUsrKVList.add(kv);
			}
		}
		
		List<KeyValueVO> retVisitKVList = new ArrayList<KeyValueVO>();
		List<SysDictionaryDTO> retVisitDicList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), RiskConstant.CODE_RES_VISIT_CD);
		if(CollectionUtils.isNotEmpty(retVisitDicList)){
			for (SysDictionaryDTO i : retVisitDicList) {
				KeyValueVO kv = new KeyValueVO();
				kv.setKey(i.getCode());
				kv.setValue(i.getCodeNm());
				retVisitKVList.add(kv);
			}
		}
		
		List<KeyValueVO> postLoanRiskKVListJSON = new ArrayList<KeyValueVO>();
		List<SysDictionaryDTO> postLoanRiskDicList = this.sysDictionaryApiService.searchGroup(CurrentThreadContext.getCurrentSysCd(), CurrentThreadContext.getCurrentOrgCd(), "RSK0028");
		if(CollectionUtils.isNotEmpty(postLoanRiskDicList)){
			for (SysDictionaryDTO i : postLoanRiskDicList) {
				KeyValueVO kv = new KeyValueVO();
				kv.setKey(i.getCode());
				kv.setValue(i.getCodeNm());
				postLoanRiskKVListJSON.add(kv);
			}
		}
		
		view.addObject("auditUsrKVListJSON", JSON.toJSON(auditUsrKVList));
		view.addObject("auditRetVisitKVListJSON", JSON.toJSON(retVisitKVList));
		view.addObject("postLoanRiskKVListJSON", JSON.toJSON(postLoanRiskKVListJSON));
		//下拉数据
		//是否
		List<KeyValueVO> yesOrNoTypeCdList = this.audReturnVisitService.searchYesOrNoTypeCdList();
		view.addObject("yesOrNoTypeCdList", yesOrNoTypeCdList);
		view.addObject("yesOrNoTypeCdListJSON", JSON.toJSON(yesOrNoTypeCdList));
		//信息确认(一致/不一致)
		List<KeyValueVO> returnVisitConfirmCdList = this.audReturnVisitService.searchReturnVisitConfirmCdList();
		view.addObject("returnVisitConfirmCdList", returnVisitConfirmCdList);
		view.addObject("returnVisitConfirmCdListJSON", JSON.toJSON(returnVisitConfirmCdList));
		//提车情况
		List<KeyValueVO> pickCardCdList = this.audReturnVisitService.searchPickCardCdList();
		view.addObject("pickCardCdList", pickCardCdList);
		//上牌情况
		List<KeyValueVO> statusCdList = this.audReturnVisitService.searchStatusCdList();
		view.addObject("statusCdList", statusCdList);
		//回访人员类型下拉数据
		List<KeyValueVO> personnelTypeCdList = this.audReturnVisitService.searchPersonnelTypeCdList();
		//过滤掉承租人回访
		if(CollectionUtils.isNotEmpty(personnelTypeCdList)){
			List<KeyValueVO> removeList = new ArrayList<KeyValueVO>();
			for (KeyValueVO kv : personnelTypeCdList) {
				if(kv.getKey().equals(AudStandingBookConstant.AUD_PER_TYP_CD_TEN)){
					removeList.add(kv);
				}
			}
			personnelTypeCdList.removeAll(removeList);
		}
		view.addObject("personnelTypeCdListJSON", JSON.toJSON(personnelTypeCdList));
		//与承租人关系
		List<KeyValueVO> relationshipCdList = this.audReturnVisitService.searchRelationshipCdList();
		view.addObject("relationshipCdListJSON", JSON.toJSON(relationshipCdList));
		
		//收入方式
		List<KeyValueVO> profitCdList = this.audReturnVisitService.searchProfitCdList(CurrentThreadContext.getCurrentSysCd(), buOrgCd);
		view.addObject("profitCdList", profitCdList);
		//运营年限
		List<KeyValueVO> bizExpList = this.audReturnVisitService.searchBizExpList();
		view.addObject("bizExpList", bizExpList);
		//主货物大类
		List<KeyValueVO> mainGdsTypCdList = this.audCreditInfoService.searchGoodsTypListByLvl("1");
		view.addObject("mainGdsTypCdList", mainGdsTypCdList);
		//货物来源
		List<KeyValueVO> goodsResList = this.audReturnVisitService.searchGoodsResList();
		view.addObject("goodsResList", goodsResList);
		//主货物结算方式
		List<KeyValueVO> gdsStlWayCdList = this.audReturnVisitService.searchGdsStlWayCdList();
		view.addObject("gdsStlWayCdList", gdsStlWayCdList);
		//司机情况
		List<KeyValueVO> driverList = this.audReturnVisitService.searchDriverList();
		view.addObject("driverList", driverList);
		//第二还款来源
		List<KeyValueVO> secondPayResCdList = this.audReturnVisitService.searchSecondPayResCdList();
		view.addObject("secondPayResCdList", secondPayResCdList);
		
		//代扣卡
		List<KeyValueVO> agentCardStateCdList = this.audReturnVisitService.searchAgentCardStateCdList();
		view.addObject("agentCardStateCdList", agentCardStateCdList);
		//设备位置
		List<KeyValueVO> eqmtAddressCdList = this.audReturnVisitService.searchEqmtAddressCdList();
		view.addObject("eqmtAddressCdList", eqmtAddressCdList);
		//车辆上户
		List<KeyValueVO> vehiclesDoorCdList = this.audReturnVisitService.searchVehiclesDoorCdList();
		view.addObject("vehiclesDoorCdList", vehiclesDoorCdList);
		
		List<KeyValueVO> powerCdList = this.audReturnVisitService.searchPowerCdList();
		view.addObject("powerCdList", powerCdList);
		//线路类型
		List<KeyValueVO> CircuitTypeCd = this.audReturnVisitService.searchCircuitTypeList();
		view.addObject("CircuitTypeCd", CircuitTypeCd);
		//装卸方式
		List<KeyValueVO> HanglingModeCd = this.audReturnVisitService.searchHanglingModeList();
		view.addObject("HanglingModeCd", HanglingModeCd);
		//区域
		
		//BaseLogUtils.info(logger, "toAddPage", "跳转到修改页面.[projectId="+projectId+",proIntId="+proIntId+"]", CurrentThreadContext.getCurrentUserName());
		return view;
	}
}

